﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HidesaburoDotNET.Core.Detecctors
{
    public class HonitsuDetector : YakuDetector
    {

        public override Yaku CheckYaku(AgariTehai agariTehai)
        {

            int h = 0;
            HaiType a0 = HaiType.None;
            for (; h < agariTehai.Hai.Count; h++)
            {
                a0 = agariTehai.Hai[h].Type;
                if (a0 != HaiType.Jihai)
                {
                    break;
                }
            }

            for (; h < agariTehai.Hai.Count; h++)
            {
                HaiType a = agariTehai.Hai[h].Type;

                if (a != a0 && a != HaiType.Jihai)
                {
                    return new Yaku();
                }
            }

            /*HaiType a = HaiType.None;
            foreach (Hai h in agariTehai.Hai)
            {
                if (h.Type != HaiType.Jihai)
                {
                    if (a == HaiType.None)
                    {
                        a = h.Type;
                    }
                    else if (a != h.Type)
                    {
                        return new Yaku();
                    }
                        
                }
            }*/


            if (agariTehai.Menzen)
            {
                return new Yaku(3, "ホンイツ");
            }
            else
            {
                return new Yaku(2, "ホンイツ");

            }
       

        }
    }
}